
package bank.account;

import bank.BankAccountObserver;
import framework.account.IAccount;


public class AccountFactory {
    public static IAccount createAccount(String type, String accountNumber) {
        IAccount account = null;
        if (type.equals("Ch")) {
            account = new CheckingAccount(accountNumber);
            account.addObserver(new BankAccountObserver(account));
            return account;
        }
        if (type.equals("S")) {
            account = new SavingAccount(accountNumber);
            account.addObserver(new BankAccountObserver(account));
            return account;
        }
        throw new RuntimeException("The type is unchecked");
    }
}
